package com.ruoyi.web.controller.app;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.project.domain.ProProject;
import com.ruoyi.project.service.IConContractService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api("合同管理")
@Controller
@RequestMapping("/api/contract")
public class ContractController{

	@Autowired
	private IConContractService conContractService;

	@ApiOperation("项目经理-手工维护需派单合同款项-关联合同列表")
	@ApiImplicitParams({@ApiImplicitParam(name = "projectId", value = "项目Id", required = true, dataType = "String")})
	@GetMapping("/getContractByProjectId")
	@ResponseBody
	public AjaxResult getContractByProjectId(Long projectId){
		// 必填项验证
		if(projectId == null){
			throw new BusinessException("项目Id不能为空");
		}
		ProProject project = new ProProject();
		project.setProjectId(projectId);
		List<Map<String, Object>> contractList = conContractService.getContractByProjectId(project);
		return AjaxResult.success(contractList);
	}

}
